package com.wb.service;

import com.wb.cache.LoaclCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.UUID;

@Component(value="redisTokenHelp")
public class RedisTokenHelp {

    private final Logger logger = LoggerFactory.getLogger(RedisTokenHelp.class);

    @Resource(name = "loaclCache")
    private LoaclCache loaclCache;

    public void create(Integer id) {
        String token = UUID.randomUUID().toString().replace("-", "");
        loaclCache.set(id == null ? null : String.valueOf(id), token);
    }

    public String get(String id) {
        return loaclCache.get(id);
    }

    public boolean existsAuth(String auth) {
        return loaclCache.existsKey(auth);
    }
}
